<?php

require_once("../../connection.php");
session_start();
$val = $_POST['val'];
$type = $_POST['type'];
$user_friends = $_SESSION['friends'];

$count = 0;
//disseminating the user array
$frns_len = sizeof($user_friends['data']);
	for($i=0;$i<$frns_len && $count<5;$i++)
	{
		$name = $user_friends["data"][$i]["name"];
		if(strpos(strtolower($name), strtolower($val))!== false)
		{
			echo '<div style="padding:5px" class="selectableRes" onclick=\'add_more_members(this);\' name="'.$type.'_'.$user_friends["data"][$i]["id"].'">'.$name.'</div>';
			$count++;
		}
	}
?>